#!/usr/bin/perl

#
# Configures a file from the environment.
#
# Usage: ./configure outfile infile
#

use strict;
use warnings;

die "bad number of arguments" if ($#ARGV != 1);

my $ofname = $ARGV[0];
my $ifname = $ARGV[1];

open FIN, "<$ifname" or die "could not open $ifname: $!";
open FOUT, ">$ofname" or die "could not open $ofname: $!";

while (my $line = <FIN>) {
	for my $key (%ENV) {
		my $value = $ENV{$key};
		$line =~ s/\@$key\@/$value/;
	}
	print FOUT $line;
}

close FIN;
close FOUT;
